package com.eshop.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.eshop.dao.GoodsOperateDao;

public class GoodsOperateServlet extends HttpServlet {

	public GoodsOperateServlet() {
		super();
	}

	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String operate = request.getParameter("operate");
		String goodsId = request.getParameter("goodsId");
		GoodsOperateDao dao = new GoodsOperateDao();
		
		if("shlves".equals(operate))
		{
			String shlves = request.getParameter("shlves");
			int i = dao.goodsShlves(shlves, goodsId);
		}
		
		if("delete".equals(operate))
		{
			int i = dao.goodsDelete(goodsId);
		}
		
		String shlves = request.getParameter("shlves");
		String type = request.getParameter("type");
		String brand = request.getParameter("brand");
		
		response.sendRedirect(request.getContextPath()+"/QueryGoodsServlet?type="+type+"&brand="+brand+"&shlves="+shlves);
	}
}
